//
//  APPLEEmoticonButton.swift
//  123
//
//  Created by pangjiaxing on 16/1/20.
//  Copyright © 2016年 pangjiaxing. All rights reserved.
//

import UIKit

class APPLEEmoticonButton: UIButton {

    var emoticon :APPLEEmoticon? {
        didSet{
            // 如果是图片表情的话
            if emoticon!.type == "0" {
                let imageName = emoticon!.fullPath
                self.setImage(UIImage(named: imageName, inBundle: APPLEEmoticonTools.sharedTools.emoticonBundle, compatibleWithTraitCollection: nil), forState: UIControlState.Normal)
                self.setTitle(nil, forState: UIControlState.Normal)
            }else if emoticon!.type == "1" {
                self.setImage(nil, forState: UIControlState.Normal)
                self.setTitle((emoticon!.code! as NSString).emoji(), forState: UIControlState.Normal)
            }else{
                print(self)
            }
        }
    }

}
